<?php
class RanksController extends AppController {

	var $name = 'Ranks';
//	var $scaffold;

	function beforeRender() {
		if ($this->layout == 'ajax') {
			Configure::write('debug', 0);
		} else {
			parent::beforeRender();
		}
	}

	function json($id = null) {
		if ($id){
			$cond = array('Rank.id'=>$id);
			$field = array('Rank.name','Rank.ch1','Rank.ch2','Rank.ch3');
			$ranks = $this->Rank->findAll($cond,$field);
		}else{
			$ranks = $this->Rank->findAll();
		}
		$this->set('ranks', json_encode($ranks));
		$this->layout = 'ajax';
	}
}
?>